﻿
namespace UsingNonMVVMElements.Test
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using UsingNonMVVMElements.Command;
    using Rhino.Mocks;

    [TestClass]
    public class GoBackWithWebBrowserDynamicParameterCommandTest
    {
        MockRepository _mockery;
        
        [TestInitialize]
        public void Initialize()
        {
            _mockery =  new MockRepository();            
        }

        [TestCleanup]
        public void Cleanup()
        {
            _mockery = null;
        }


        [TestMethod]
        public void CanExecuteTestWhenNavigationPossible()
        {
            GoBackWithWebBrowserDynamicParameterCommand target = 
                new GoBackWithWebBrowserDynamicParameterCommand();

            IWebBrowser browser = _mockery.Stub<IWebBrowser>();
            browser.CanGoBack = true;

            Assert.IsTrue(target.CanExecute(browser));
        }

        [TestMethod]
        public void CanExecuteTestWhenNavigationNotPossible()
        {
            GoBackWithWebBrowserDynamicParameterCommand target =
                new GoBackWithWebBrowserDynamicParameterCommand();

            IWebBrowser browser = _mockery.Stub<IWebBrowser>();
            browser.CanGoBack = false;

            Assert.IsFalse(target.CanExecute(browser));
        }

        [TestMethod]
        public void CanExecuteTestWhenNullParameter()
        {
            GoBackWithWebBrowserDynamicParameterCommand target =
                new GoBackWithWebBrowserDynamicParameterCommand();

            //IWebBrowser browser = _mockery.Stub<IWebBrowser>();
            //browser.CanGoBack = true;

            Assert.IsTrue(target.CanExecute(null));
        }
    }
}
